<template>
  <!-- 水量报表 -->
  <div class="dayReport">
    <!-- new Date() -->
    <button class="leftTreetitleButton" @click="treeShowOrClose = true" v-if="!treeShowOrClose">
      <i class="el-icon-caret-right"></i>
    </button>
    <div class="leftTree" v-if="treeShowOrClose">
      <!-- 树形图 -->
      <!-- <leftTree></leftTree> -->
      <waterMeterLeftTree class="waterMeterLeftTree" @clickClose='clickClose' @areaIf='areaIf' />
    </div>

    <div :class="[{rightcontant:treeShowOrClose},{rightcontant2:!treeShowOrClose}]">
      <!-- 搜索框-->
      <el-date-picker v-if="false" v-model="value2" style="width:200px;" type="datetime" placeholder="选择日期时间" align="right" :picker-options="pickerOptions">
      </el-date-picker>
      <div class="searchDataTop">
        <!-- {{suoS}} range -->
        <searchComponents :searchData="searchData" :optionsZi="optionsZi" :searchOptionTable="searchOptionTable" @searchCallBack="searchCallBack"></searchComponents>
        <!-- 搜索按钮 -->

        <!-- <el-button type="primary" size="mini" plain @click="sunS_F" icon="el-icon-search" style="margin-top:95px;margin-right:30px;margin-bottom:25px;">搜索</el-button> -->
        <div class="line"></div>
        <div class="right_row">
          <rightButtons @sunS_F="sunS_F" @emptySearch="emptySearch" @configuration="configuration" class="right_buttons"></rightButtons>
        </div>
      </div>
      <!-- 表格 -->
      <div class="out">
        <!--数据列表-->
        <!-- 字典 -->
        <dictionaries :searchData='searchData' :modelType='modelType' @optionData="dictionariesCallBack"></dictionaries>
        <el-table ref="multipleTable" :data="dataAttribute" v-loading.body="loading" border fit max-height="511px" highlight-current-row size="mini" :cell-style="{padding:'5px 0'}" @selection-change="handleSelectionChange" :height="tableHight">
          <!-- show-summary -->
          <el-table-column align="center" type="selection" :show-overflow-tooltip="true" width="45"></el-table-column>
          <el-table-column fixed align="center" label="序号" type="index" :index="indexMethod" width="54px">
          </el-table-column>
          <el-table-column le-column fixed prop="customerNo" label="用户号" align="center" :show-overflow-tooltip="true" width="150"></el-table-column>
          <el-table-column fixed prop="waterNo" label="表身号" align="center" :show-overflow-tooltip="true" width="100"></el-table-column>
          <el-table-column fixed prop="setupAddress" label="用水地址" align="center" :show-overflow-tooltip="true" width="200"></el-table-column>
          <el-table-column align="center" v-for="item in searchData" v-if="item.tableSign" :key="item.id" :label="item.CN" :show-overflow-tooltip="true" min-width="140px">
            <template slot-scope="scope">{{item.type === 'select' ? optionDatas(item.typeGroupCode?optionsZi[item.EN]:searchOptionTable[item.EN],scope.row[item.EN]):scope.row[item.EN]}}</template>
          </el-table-column>
          <!-- <el-table-column
            fixed="right"
            prop="AvTolNum"
            label="平均值"
            align="center"
            :show-overflow-tooltip="true"
            width="150"
          ></el-table-column> -->
          <el-table-column fixed="right" prop="TolNum" label="合计" align="center" :show-overflow-tooltip="true" width="150"></el-table-column>
        </el-table>
        <el-pagination class="pagination" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="pagetotal"></el-pagination>
      </div>

    </div>
    <!-- 查看组件 -->
    <examine :DialogVisibleMod="DialogVisibleExamine" :modData="examineData" :optionsZi="optionsZi" :searchOptionTable="searchOptionTable" :attributeOrder="searchData" @examineDialog="examineDialog"></examine>
  </div>
</template>
<script>
//引入组件
import {
  SearchCForL,
  searchComponents,
  buttonhurdle,
  modificationi,
  waterMeterLeftTree,
  examine,
  rightButtons,
  dictionaries,
  importXlsx,
} from '@/views/components/FLPage'
// import searchComponents from './searchComponents'
import {
  addFlWaterMeterRecord, //增加
  deleteFlWaterMeterRecord, //删除
  searchFlWaterMeterRecord, //分页查询
  modifyFlWaterMeterRecord, //修改
  getFlWaterMeterRecord, //根据ID获取
  exprotXls, //导出xlsx数据
  downTem, //导出下载模板
  getDaily2, //日报二次处理
  getDaily, //获取日报总条数
  flWaterMeterInfoSearch,
  flWaterReportGetData,
} from '@/api/waterAnalysis/flWaterReport/index'
export default {
  components: {
    buttonhurdle,
    modificationi,
    waterMeterLeftTree,
    examine,
    searchComponents,
    importXlsx,
    rightButtons,
    dictionaries,
  },
  name: 'dayReport',
  mounted() {
    this.$nextTick(() => {
      // 点击前一个月
      /*  let prevBtn = document.querySelector('el-date-picker__prev-btn')
      prevBtn.addEventListener('click', () => {
        alert(111)
      }) */
    })
  },
  data() {
    return {
      //日期选择范围在一个月内 ,从本月1号开始 -- 到本月底结束
      pickerOptions: {
        disabledDate(time) {
          let startMonths = 60 * 60 * 1000 * 24 * new Date().getDate()

          let nowMonth = new Date().getMonth() + 1,
            lastDay = 0
          if (
            nowMonth == 1 ||
            nowMonth == 3 ||
            nowMonth == 5 ||
            nowMonth == 7 ||
            nowMonth == 8 ||
            nowMonth == 10 ||
            nowMonth == 12
          ) {
            lastDay = 31
          } else {
            lastDay = 30
          }
          let endMonths = 60 * 60 * 1000 * 24 * (lastDay - new Date().getDate())

          return (
            time.getTime() > new Date().getTime() + endMonths ||
            time.getTime() < new Date().getTime() - startMonths
          )
        },
      },

      value2: '',
      tableHight: 520,
      dateList: [],
      loading: false,
      importUrl: `/api/cb/flWaterMeterRecord/importXls`,
      //搜索框
      suoS: {},
      treeShowOrClose: false,
      //   搜索组件的数据
      searchData: [
        {
          EN: 'id',
          CN: 'id',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'readNumDate',
          CN: '开始时间',
          value: this.getBeforeDate(7),
          //defaultDayDate: (new Date().getDate() - 7),
          defaultDayDate: this.getBeforeDate(7),
          report: true,
          type: 'dateDate',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: true,
          addSign: false,
          tableSign: false,
          examineSign: false,
          examineDisabled: false,
          modificationSign: false,
        },

        {
          // readNumDate1
          EN: 'readNumDate1',
          // EN: "lastNumDate",
          CN: '结束时间',
          value: this.getBeforeDate(0),
          defaultDayDate: this.getBeforeDate(0),
          // value: new Date(),
          // value: this.endDatemoren,
          type: 'dateDate',
          report: true,
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: true,
          addSign: true,
          tableSign: false,
          examineSign: false,
          examineDisabled: false,
          modificationSign: false,
        },
        {
          EN: 'customerNo',
          CN: '用户号',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'waterNo',
          CN: '表身号',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'setupAddress',
          CN: '用水地址',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          typeGroupCode: 'meterread_type',
          result: true,
          sign: true,
          searchSign: false,
          addSign: false,
          tableSign: false,
          examineSign: false,
          examineDisabled: false,
          modificationSign: false,
        },
        {
          EN: 'readType',
          CN: '抄表方式',
          value: '',
          type: 'select',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          typeGroupCode: 'meterread_type',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        // {
        //   EN: "lastNumDate",
        //   CN: "上期抄表日期",
        //   value: "",
        //   type: "date",
        //   option: [],
        //   Exp: "^.{3,20}$",
        //   err: "长度为3-20的所有字符!",
        //   result: true,
        //   sign: true,
        //   searchSign: false,
        //   addSign: true,
        //   tableSign: false,
        //   examineSign: true,
        //   examineDisabled: false,
        //   modificationSign: true
        // },
        {
          EN: 'lastNum',
          CN: '上期读数',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        // {
        //   EN: "readNumDate",
        //   CN: "本期抄表日期",
        //   value: "",
        //   type: "date",
        //   option: [],
        //   Exp: "^.{3,20}$",
        //   err: "长度为3-20的所有字符!",
        //   result: true,
        //   sign: true,
        //   searchSign: false,
        //   addSign: true,
        //   tableSign: false,
        //   examineSign: true,
        //   examineDisabled: false,
        //   modificationSign: true
        // },
        {
          EN: 'dayCount',
          CN: '跨越天数',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'readNum',
          CN: '当期读数',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'useCount',
          CN: '用水量',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'freeingData',
          CN: '缓存数据',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'freeingDate',
          CN: '缓存日期',
          value: '',
          type: 'date',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'tapsatatus',
          CN: '阀门状态',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'addresscode',
          CN: '表计地址码',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'signalintensity',
          CN: '信号强度',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'imei',
          CN: 'IMEI',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'batterystatus',
          CN: '电池状态',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'version',
          CN: '版本号',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'cycleOfUpload',
          CN: 'NB表读数上报周期',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'AvTolNum',
          CN: '平均值',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'TolNum',
          CN: '合计',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
      ],
      //   搜索组件的数据
      searchDataDong: [
        {
          EN: 'id',
          CN: 'id',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'readNumDate',
          CN: '开始时间',
          value: this.getBeforeDate(7),
          // value: (new Date().getDate() - 7),
          defaultDayDate: this.getBeforeDate(7),
          report: true,
          type: 'dateDate',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: true,
          addSign: false,
          tableSign: false,
          examineSign: false,
          examineDisabled: false,
          modificationSign: false,
        },

        {
          // readNumDate1
          EN: 'readNumDate1',
          // EN: "lastNumDate",
          CN: '结束时间',
          value: this.getBeforeDate(0),
          defaultDayDate: this.getBeforeDate(0),
          // value: new Date().getDate(),
          // value: this.endDatemoren,
          type: 'dateDate',
          report: true,
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: true,
          addSign: true,
          tableSign: false,
          examineSign: false,
          examineDisabled: false,
          modificationSign: false,
        },
        {
          EN: 'customerNo',
          CN: '用户号',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: true,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'waterNo',
          CN: '表身号',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: true,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'setupAddress',
          CN: '用水地址',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          typeGroupCode: 'meterread_type',
          result: true,
          sign: true,
          searchSign: true,
          addSign: false,
          tableSign: false,
          examineSign: false,
          examineDisabled: false,
          modificationSign: false,
        },
        {
          EN: 'readType',
          CN: '抄表方式',
          value: '',
          type: 'select',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          typeGroupCode: 'meterread_type',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        // {
        //   EN: "lastNumDate",
        //   CN: "上期抄表日期",
        //   value: "",
        //   type: "date",
        //   option: [],
        //   Exp: "^.{3,20}$",
        //   err: "长度为3-20的所有字符!",
        //   result: true,
        //   sign: true,
        //   searchSign: false,
        //   addSign: true,
        //   tableSign: false,
        //   examineSign: true,
        //   examineDisabled: false,
        //   modificationSign: true
        // },
        {
          EN: 'lastNum',
          CN: '上期读数',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        // {
        //   EN: "readNumDate",
        //   CN: "本期抄表日期",
        //   value: "",
        //   type: "date",
        //   option: [],
        //   Exp: "^.{3,20}$",
        //   err: "长度为3-20的所有字符!",
        //   result: true,
        //   sign: true,
        //   searchSign: false,
        //   addSign: true,
        //   tableSign: false,
        //   examineSign: true,
        //   examineDisabled: false,
        //   modificationSign: true
        // },
        {
          EN: 'dayCount',
          CN: '跨越天数',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'readNum',
          CN: '当期读数',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'useCount',
          CN: '用水量',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'freeingData',
          CN: '缓存数据',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'freeingDate',
          CN: '缓存日期',
          value: '',
          type: 'date',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'tapsatatus',
          CN: '阀门状态',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'addresscode',
          CN: '表计地址码',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'signalintensity',
          CN: '信号强度',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'imei',
          CN: 'IMEI',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'batterystatus',
          CN: '电池状态',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'version',
          CN: '版本号',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'cycleOfUpload',
          CN: 'NB表读数上报周期',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'AvTolNum',
          CN: '平均值',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'TolNum',
          CN: '合计',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'tolnum1',
          CN: '合计起',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
        {
          EN: 'tolnum2',
          CN: '合计止',
          value: '',
          type: 'input',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
        },
      ],

      //添加弹窗的数据模型
      diaDataAdd: {
        yyqName: '',
        pqName: '',
        pqNum: '',
        BH: '',
      },
      //删除----Start--------------------------------------
      deleteDataList: [],
      //删除----End----------------------------------------

      //查看----Start--------------------------------------

      //查看的弹窗控制器
      DialogVisibleExamine: false,

      //查看的数据
      examineData: {},

      //查看----End----------------------------------------

      //表格数据
      //后端传来的数据
      dataAttribute: [],
      //表格选中
      multipleSelection: [],
      //分页
      currentPage: 1, //当前页
      pagesize: 10, //每页条数
      pagetotal: 0, //总条数,
      modelType: 'table',
      optionsZi: [],
      searchOptionTable: [],
      startDatemoren: '',
      endDatemoren: '',
      // endDatemoren:''
    }
  },
  computed: {
    optionDatas() {
      return function (arr, val) {
        if (arr) {
          for (let i = 0; i < arr.length; i++) {
            if (arr[i].value == val) {
              return arr[i].label
            }
          }
        }
      }
    },
  },
  created() {
    console.log(
      '++++++++',
      new Date(+new Date() - 24 * 60 * 60 * 1000).getMonth() + 1,
      new Date(+new Date() - 24 * 60 * 60 * 1000).getDate()
    )
    // this.loading =true
    this.getToDay()
    // this.ceshidongtai()
    // this.forData(this.currentPage, this.pagesize, this.suoS);
  },
  methods: {
    // 获取当天时间
    getToDay() {
      var aDate = new Date()
      var month =
        aDate.getMonth() < 9
          ? '0' + (aDate.getMonth() + 1)
          : aDate.getMonth() + 1
      var date = aDate.getDate() <= 9 ? '0' + aDate.getDate() : aDate.getDate()
      console.log(date, 66222)
      var toDate = aDate.getFullYear() + '-' + month + '-' + date
      var mmhh = '00:00:00'
      var mmHhArr = [toDate, mmhh]
      console.log(mmHhArr, 662223)
      var mmHhStr = mmHhArr.join(' ')
      console.log(mmHhStr, 662223)
      this.endDatemoren = mmHhStr
      // this.endDatemoren = mmHhStr
      return mmHhStr
    },
    getBeforeDate(n) {
      var n = n
      var d = new Date()
      var year = d.getFullYear()
      var mon = d.getMonth() + 1
      var day = d.getDate()
      if (day <= n) {
        if (mon > 1) {
          mon = mon - 1
        } else {
          year = year - 1
          mon = 12
        }
      }
      d.setDate(d.getDate() - n)
      year = d.getFullYear()
      mon = d.getMonth() + 1
      day = d.getDate()
      let s =
        year +
        '-' +
        (mon < 10 ? '0' + mon : mon) +
        '-' +
        (day < 10 ? '0' + day : day)
      return s
    },
    // console.log(getBeforeDate(1));//昨天的日期
    //   console.log(getBeforeDate(7));//前七天的日期
    // 左侧小区条件
    areaIf(areaCode) {
      // console.log(areaCode);
      // this.areaCode = areaCode
      // this.forData(this.currentPage, this.pagesize, this.suoS);
      console.log(areaCode, 666)
      this.areaCode = areaCode
      this.suoS.communityCode = areaCode
      this.currentPage = 1
      this.forData(this.currentPage, this.pagesize, this.suoS)
    },
    clickClose(res) {
      // console.log(res,999);
      if (res === '点击隐藏') {
        this.treeShowOrClose = false
      }
    },
    // 搜索栏清空
    // clearSearch(msg){
    //   if (msg == '清空') {
    //   console.log(msg,'父组件');
    //   this.forData(this.currentPage, this.pagesize); //刷新列表
    //   }
    // },
    // 配置
    configuration(msg) {
      if (msg == '配置') {
        console.log(msg)
      }
    },
    // 重置
    emptySearch(msg) {
      if (msg == '重置') {
        this.areaCode = ''
        this.currentPage = 1
        this.suoS.hasOwnProperty('readNumDate') &&
          Object.keys(this.suoS).forEach((item) => {
            this.suoS[item] = ''
          })
        this.forData(this.currentPage, this.pagesize, this.suoS)
      }
    },
    // 字典组件回调
    dictionariesCallBack([a = {}, b = {}]) {
      // 正常字典
      this.optionsZi = a
      // 跨表字典
      this.searchOptionTable = b
      this.forData(this.currentPage, this.pagesize, this.suoS)
    },
    //搜索
    sunS_F(msg) {
      let type = 'warning'
      if (!this.suoS['readNumDate']) {
        this.$message({ type, message: '请选择开始时间' })
        return
      }
      if (!this.suoS['readNumDate1']) {
        this.$message({ type, message: '请选择结束时间' })
        return
      }

      if (this.suoS.readNumDate && this.suoS.readNumDate1) {
        if (
          new Date(this.suoS.readNumDate).getTime() >
          new Date(this.suoS.readNumDate1).getTime()
        ) {
          this.$message({
            type: 'warning',
            message: '开始时间大于结束时间',
          })
          return
        }
      }
      console.log(this.suoS['readNumDate'], this.suoS['readNumDate1'], 66)
      this.formatEveryDay(this.suoS['readNumDate'], this.suoS['readNumDate1'])
      this.currentPage = 1
      this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
    },
    formatEveryDay(start, end) {
      let dateList = []
      var startTime = this.getDate(start)
      var endTime = this.getDate(end)
      while (endTime.getTime() - startTime.getTime() >= 0) {
        var year = startTime.getFullYear()
        var month =
          startTime.getMonth() + 1 < 10
            ? '0' + (startTime.getMonth() + 1)
            : startTime.getMonth() + 1
        var day =
          startTime.getDate().toString().length == 1
            ? '0' + startTime.getDate()
            : startTime.getDate()
        dateList.push(year + '-' + month + '-' + day)
        startTime.setDate(startTime.getDate() + 1)
      }
      this.dateList = dateList
      console.log(dateList, 369)
      return dateList
    },
    getDate(datestr) {
      var temp = datestr.split('-')
      var date = new Date(temp[0], temp[1] - 1, temp[2])
      return date
    },
    //查询组件回调
    searchCallBack(newData) {
      // console.log(newData,'查询组件回调');
      let obj = {}
      for (let i = 0; i < newData.length; i++) {
        obj[newData[i].EN] = newData[i].value
        // console.log(newData[i].EN,newData[i].value,666666666);
      }
      console.log(obj)
      this.suoS = obj
    },
    // async ceshidongtai(){
    //   let obj = {date:['2020-05-01','2020-05-02'],value:['55','66']}
    //   let dateTime = obj.date
    //   let valueArr = obj.value
    //   let searchObj = {}
    //   for (let i = 0; i < dateTime.length; i++) {
    //     const element = dateTime[i];
    //     searchObj['EN'] = element
    //     searchObj['CN'] = element
    //     searchObj['value'] = ''
    //     this.searchData.push(searchObj)
    //     searchObj = {}
    //   }

    // },
    async getDataList(page, size, suoS) {
      const result = await flWaterReportGetData(page, size, suoS)
      console.log(result, 357159)
    },
    // 动态添加searchData数组
    async DynamicallyAddSearchData(page, size, suoS) {
      let searchDataArr = this.searchDataDong
      let ObjCanShu = {
        readNumDate: suoS['readNumDate'],
        'readNumDate1:': suoS['readNumDate1'],
      }
      this.formatEveryDay(suoS['readNumDate'], suoS['readNumDate1'])
      console.log(1112222333)
      // this.dateList
      let searchArr = []
      let searchObj = {}

      let searchMap = this.dateList.map((val) => {
        return {
          EN: val,
          CN: val,
          value: 0,
          tableSign: true,
          searchSign: false,
        }
      })
      console.log(searchMap, 998)
      this.searchData = [...searchDataArr, ...searchMap]
      // -----------------------------------------------------
      console.log(this.searchData, 33666)

      if (!suoS.readNumDate) suoS.readNumDate = this.getBeforeDate(7)
      if (!suoS.readNumDate1) suoS.readNumDate1 = this.getBeforeDate(0)

      if (this.areaCode) suoS.communityCode = this.areaCode

      // 水表资料分页条件查询
      const res = await flWaterMeterInfoSearch(page, size, suoS)
      console.log(res, '水表资料分页条件查询')
      this.pagetotal = res.data.total

      const result = await flWaterReportGetData(page, size, suoS)
      console.log(result.data, '查询第二个参数')
      this.dataAttribute = result.data
      if (!result.data.length) {
        this.pagetotal = 0
      }

      // let dateListRiQiObj = result.data[0]

      // 组合数据
      // dataAttribute 分页条件查询数据
      // dateListRiQiObj 日期对象
      // dateList  日期数组

      // for (let i = 0; i < dataAttribute.length; i++) {
      //   let element = dataAttribute[i];
      //   console.log(element,i,element.id,111);
      //   for (const key in dateListRiQiObj) {
      //     let objList = dateListRiQiObj[key];
      //     console.log(key,objList,222);
      //     for (let j = 0; j < this.dateList.length; j++) {
      //       let riqi = this.dateList[j];
      //       console.log(riqi,j,this.dateList.length,333);
      //       if (element.id === key) {
      //         console.log(this.dateList.length,369);
      //         element['TolNum'] = objList[this.dateList.length]
      //         element[riqi] = objList[j]
      //       }
      //     }
      //   }
      // }

      //this.$nextTick(() => {

      // console.log(this.searchData, 89)

      this.tableHight = 521
      this.$nextTick(() => {
        this.tableHight = 520
      })
      //})
      console.log(this.dataAttribute, 357)

      this.loading = false
    },
    //渲染数据初始
    forData(page, size, searchData) {
      this.loading = true
      // 获取表格 总条数  每页条数
      // this.getDailyToll(page, size, searchData)
      this.DynamicallyAddSearchData(page, size, searchData)
      // searchFlWaterMeterRecord(page, size, searchData).then(response => {
      //   this.pagetotal = response.data.total;
      //   this.dataAttribute = response.data.list;
      // });
    },
    //添加用户--新增表单组件传来的参数
    toAdd(addData) {
      let obj = {}
      for (let i = 0; i < addData.length; i++) {
        obj[addData[i].EN] = addData[i].value
      }
      addFlWaterMeterRecord(obj)
        .then((response) => {
          this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
          this.$message({
            message: '添加成功',
            type: 'success',
          })
        })
        .catch(() => {
          this.$message.error('添加失败')
        })
    },
    //按钮栏传递了删除命令
    toDelete(orderstring) {
      this.$confirm('确认删除？')
        .then((_) => {
          let idArr = []
          for (let i = 0; i < this.deleteDataList.length; i++) {
            idArr.push(this.deleteDataList[i].id)
          }
          if (idArr.length == 0) {
            this.$message({
              message: '请选择要删除的数据',
              type: 'warning',
            })
            return
          }
          deleteFlWaterMeterRecord(idArr)
            .then((response) => {
              this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
              this.$message({
                message: '删除成功',
                type: 'success',
              })
            })
            .catch((error) => {
              this.$message({
                message: '删除失败',
                type: 'warning',
              })
            })
        })
        .catch((_) => {})
    },
    //单项删除
    deleteList(id) {
      let arrId = [id]
      this.$confirm('确认删除？')
        .then((_) => {
          deleteFlWaterMeterRecord(arrId).then((response) => {
            this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
            this.$message({
              message: '删除成功',
              type: 'success',
            })
          })
          done()
        })
        .catch((_) => {})
    },
    //查看
    makeExaId(id) {
      getFlWaterMeterRecord(id)
        .then((response) => {
          let copyDialog = true
          this.DialogVisibleExamine = copyDialog
          // console.log(response);
          this.examineData = response.data
        })
        .catch((error) => {
          alert('获取失败')
        })
    },
    //查看关闭弹窗
    examineDialog(dialogVisibleMod) {
      this.DialogVisibleExamine = false
    },

    //修改
    modifyData(value, modData) {
      if (value) {
        let id = modData.id
        modifyFlWaterMeterRecord(id, modData)
          .then((response) => {
            this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
          })
          .catch((error) => {
            this.$message({
              message: '修改失败',
              type: 'warning',
            })
            this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
          })
      } else {
        this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
      }
    },
    //表格选中事件
    handleSelectionChange(val) {
      this.multipleSelection = val
      //传递删除的参数
      this.deleteDataList = val
    },

    //分页
    handleSizeChange(val) {
      console.log('每页 ' + val + ' 条')
      this.pagesize = val
      this.forData(this.currentPage, val, this.suoS)
    },
    handleCurrentChange(val) {
      console.log('当前页: ' + val)
      this.currentPage = val
      this.forData(val, this.pagesize, this.suoS)
    },
    // 序号
    indexMethod(index) {
      var currentPage = this.currentPage
      var pagesize = this.pagesize
      this.$nextTick(function () {
        currentPage = this.currentPage
        pagesize = this.pagesize
      })
      return currentPage * pagesize - pagesize + 1 + index
    },
    // 下载模板请求
    exprotXlsx: exprotXls,
    downloadFile: downTem,
    //工具栏组件传来的参数
    // FTableFunction(attributeOrderCloneTwiceL) {
    //   this.attributeOrder = attributeOrderCloneTwiceL;
    // },
  },
}
</script>
<style scoped src="@/styles/allCss.css"></style>
<style lang="scss" scoped>
.dayReport {
  display: flex;
  .line {
    border-top: 1px solid #e6e6e6;
    margin: 0 30px;
  }
  .right_row {
    padding: 25px 30px;
  }
  .right_buttons {
    text-align: right;
  }
  .leftTreetitleButton {
    margin-top: 10px;
    border: 0;
    height: 32px;
  }
  .leftTree {
    width: 14.2%;
    .waterMeterLeftTree {
      border: 1px soild #ccc;
    }
  }
  .rightcontant {
    width: 85.8%;
    /deep/ .el-table--mini {
      .gutter {
        display: table-cell !important;
      }
      /deep/.el-table__body-wrapper {
        .el-table__body {
          tbody {
            /deep/.el-table__row {
              height: 45px !important;
              line-height: 45px !important;
              .is-center {
                .cell {
                  height: 45px !important;
                  line-height: 45px !important;
                }
              }
            }
            // .current-row{
            //   .is-center{
            //     height: 47px !important;
            //   }
            // }
          }
        }
      }
      /deep/.el-table__fixed-right {
        .el-table__body {
          tbody {
            /deep/.el-table__row {
              height: 45px !important;
              line-height: 45px !important;
              .is-center {
                .cell {
                  height: 45px !important;
                  line-height: 45px !important;
                }
              }
            }
            // .current-row{
            //   .is-center{
            //     height: 47px !important;
            //   }
            // }
          }
        }
      }
      /deep/.el-table__fixed {
        .el-table__body {
          tbody {
            /deep/.el-table__row {
              height: 45px !important;
              line-height: 45px !important;
              .is-center {
                .cell {
                  height: 45px !important;
                  line-height: 45px !important;
                }
              }
            }
            // .current-row{
            //   .is-center{
            //     height: 47px !important;
            //   }
            // }
          }
        }
      }
    }
    .buttonTop {
      // display: flex;
      // flex-direction: row;
      // justify-content: space-between;
      // align-items: center;
      position: relative;
      .rightButtons {
        position: absolute;
        right: 0;
        padding-left: 50px;
        display: flex;
        flex-direction: row;
        justify-content: end;
        width: 300px;
      }
      // .hunt_sunS_F{
      //   float: right;
      //   margin: 10px;
      // }
    }
    .do {
      display: flex;
    }
    .pagination {
      margin-top: 15px;
    }
  }
  .rightcontant2 {
    width: 97%;
    /deep/ .el-table--mini {
      .gutter {
        display: table-cell !important;
      }
      /deep/.el-table__body-wrapper {
        .el-table__body {
          tbody {
            /deep/.el-table__row {
              height: 45px !important;
              line-height: 45px !important;
              .is-center {
                .cell {
                  height: 45px !important;
                  line-height: 45px !important;
                }
              }
            }
            // .current-row{
            //   .is-center{
            //     height: 47px !important;
            //   }
            // }
          }
        }
      }
      /deep/.el-table__fixed-right {
        .el-table__body {
          tbody {
            /deep/.el-table__row {
              height: 45px !important;
              .is-center {
                .cell {
                  height: 45px !important;
                }
              }
            }
            // .current-row{
            //   .is-center{
            //     height: 47px !important;
            //   }
            // }
          }
        }
      }
      /deep/.el-table__fixed {
        .el-table__body {
          tbody {
            /deep/.el-table__row {
              height: 45px !important;
              line-height: 45px !important;
              .is-center {
                .cell {
                  height: 45px !important;
                  line-height: 45px !important;
                }
              }
            }
            // .current-row{
            //   .is-center{
            //     height: 47px !important;
            //   }
            // }
          }
        }
      }
    }
    .buttonTop {
      // display: flex;
      // flex-direction: row;
      // justify-content: space-between;
      // align-items: center;
      position: relative;
      .is-plain {
        position: absolute;
        right: 0;
        padding-left: 50px;
        width: 300px;
      }
    }
    .do {
      display: flex;
    }
    .pagination {
      text-align: left;
      margin-top: 15px;
    }
  }
}
</style>
